package com.financial.business.management.service.impl;

import com.financial.business.management.constants.FinancialPlatfromConfigEnumConstants;
import com.financial.business.management.dao.FinancialPlatfromConfigDao;
import com.financial.business.management.domain.FinancialPlatfromConfigDO;
import com.financial.business.management.service.FinancialPlatfromConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class FinancialPlatfromConfigServiceImpl implements FinancialPlatfromConfigService {
	@Autowired
	private FinancialPlatfromConfigDao financialPlatfromConfigDao;


	@Override
	public FinancialPlatfromConfigDO get(Integer id) {

		return financialPlatfromConfigDao.get(id);
	}

	@Override
	public List<FinancialPlatfromConfigDO> list(Map<String, Object> map) {
		return financialPlatfromConfigDao.list(map);
	}

	@Override
	public int count(Map<String, Object> map){
		return financialPlatfromConfigDao.count(map);
	}

	@Override
	public int save(FinancialPlatfromConfigDO financialPlatfromConfig) {

		return financialPlatfromConfigDao.save(financialPlatfromConfig);
	}

	@Override
	public int update(FinancialPlatfromConfigDO financialPlatfromConfig) {
		return financialPlatfromConfigDao.update(financialPlatfromConfig);
	}

	@Override
	public int remove(Integer id){
		return financialPlatfromConfigDao.remove(id);
	}
	
	@Override
	public int batchRemove(Integer[] ids){
		return financialPlatfromConfigDao.batchRemove(ids);
	}

	@Override
	public int getPlatfromId(String platfromAppname) {
        Map<String, Object> AppnameMap = new HashMap<>();
        AppnameMap.put("platfromMarking",platfromAppname);
        AppnameMap.put("isDelete", FinancialPlatfromConfigEnumConstants.ENUM_ISDELETE_UNDEL);
        List<FinancialPlatfromConfigDO> list = financialPlatfromConfigDao.list(AppnameMap);
        FinancialPlatfromConfigDO financialPlatfromConfigDO = list != null && list.size() > 0 ? list.get(0) : null;
        return financialPlatfromConfigDO.getId();
	}

    @Override
    public Map<String,Object> getPlatfromConfig(String username, String passWord) {
        Map<String, Object> requestMap = new HashMap<>();
        Map<String, Object> resultMap = new HashMap<>();
        resultMap.put("username",username);
        resultMap.put("passWord",passWord);
        resultMap.put("is_delete", FinancialPlatfromConfigEnumConstants.ENUM_ISDELETE_UNDEL);
        List<FinancialPlatfromConfigDO> list = financialPlatfromConfigDao.list(resultMap);
        if(null != list ){
            FinancialPlatfromConfigDO financialPlatfromConfigDO = list.size() > 0 ? list.get(0) : null;
            String password = financialPlatfromConfigDO.getPassword();
            String platfromMarking = financialPlatfromConfigDO.getPlatfromMarking();
            String salt = financialPlatfromConfigDO.getSalt();

            String secretkey = financialPlatfromConfigDO.getSecretkey();
            String userName = financialPlatfromConfigDO.getUsername();
            requestMap.put("username",userName);
            requestMap.put("password",password);
            requestMap.put("platfromMarking",platfromMarking);
            requestMap.put("salt",salt);
            requestMap.put("secretkey",secretkey);
        }
    
        return requestMap;
    }




}
